import 'package:dio/dio.dart';
import 'models/api_response.dart';
abstract class BaseHttpClient {
  // 基础配置方法
  void setBaseUrl(String baseUrl);
  void setHeaders(Map<String, String> headers);
  void setTimeout(Duration connectTimeout, Duration receiveTimeout, Duration sendTimeout);

  // 拦截器管理
  void addInterceptor(Interceptor interceptor);
  void removeInterceptor(Interceptor interceptor);
  void clearInterceptors();

  // 核心请求方法
  Future<ApiResponse<T>> get<T>(
      String path, {
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  Future<ApiResponse<T>> post<T>(
      String path, {
        dynamic data,
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  Future<ApiResponse<T>> put<T>(
      String path, {
        dynamic data,
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  Future<ApiResponse<T>> delete<T>(
      String path, {
        dynamic data,
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  Future<ApiResponse<T>> patch<T>(
      String path, {
        dynamic data,
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  // 请求取消
  void cancelRequest(String requestId);
  void cancelAllRequests();

  // 文件上传
  Future<ApiResponse<T>> upload<T>(
      String path, {
        required String filePath,
        required String fileKey,
        Map<String, dynamic>? data,
        ProgressCallback? onSendProgress,
        Options? options,
        String? requestId,
      });

  // 文件下载
  Future<ApiResponse<T>> download<T>(
      String path, {
        required String savePath,
        ProgressCallback? onReceiveProgress,
        Map<String, dynamic>? queryParameters,
        Options? options,
        String? requestId,
      });

  // 认证相关
  void setAuthToken(String token);
  void clearAuthToken();

  // 工具方法
  bool isNetworkError(DioException error);
  bool isServerError(int statusCode);

  // 资源释放
  void dispose();
}